import React from 'react';
import {connect} from 'react-redux';
import {Redirect} from 'react-router-dom';

// 在需要做校验的路由页面组件中做判断
class Shelf extends React.Component {
  render() {
    if(this.props.userName){
      return (
        <div>这是书架页面</div>
      );
    }
    else {
      return (<Redirect to='/login?redirect=/shelf' />)
    }
  }
};

export default connect(
  state => {
    return {
      userName:state.user.userName
    }
  },
  null
)(Shelf);
